﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient ;

/// <summary>
/// users 的摘要说明
/// </summary>
public class users : SQLHelper
{
    private string _id;
    private string _ps;
    private string _name;
    private string _number;
    private string _tel;
    private string _rte;
    private string _tte;
    private string _penson;
    private string _num;
    private string _price;
    private string _type;
    private string _money;
    private string _free;
    private string _pay;


    public string pay
    {
        get { return _pay; }
        set { _pay = value; }
    }

    public string id
    {
        get { return _id; }
        set { _id = value; }
    }
    public string ps
    {
        get { return _ps; }
        set { _ps = value; }
    }
    public string name
    {
        get { return _name; }
        set { _name = value; }
    }
    public string number
    {
        get { return _number; }
        set { _number = value; }
    }
    public string tel
    {
        get { return _tel; }
        set { _tel = value; }
    }
    public string rte
    {
        get { return _rte; }
        set { _rte = value; }
    }
    public string tte
    {
        get { return _tte; }
        set { _tte = value; }
    }
    public string penson
    {
        get { return _penson; }
        set { _penson = value; }
    }
    public string num
    {
        get { return _num; }
        set { _num = value; }
    }
     public string price
    {
        get { return _price; }
        set { _price = value; }
    }
     public string type
    {
        get { return _type; }
        set { _type = value; }
    }
     public string money
     {
         get { return _money; }
         set { _money = value; }
     }
     public string free
     {
         get { return _free; }
         set { _free = value; }
     }

    public users()
    {
        //
        // TODO: 在此处添加构造函数逻辑
        //
    }
    public int isExist(users tmp)
    {

        string sql = "select count(*) from Register where id='" + tmp._id + "'";
        int result = 0;
        result = tmp.ExeScale(sql);
        return result;



    }
   
    //登录
    public int login(users tmp)
    {
        string sql = "select count(*) from Register where id='" + tmp.id + "'" +
          " and password='" + tmp.ps + "'";
        int result = 0;
        result = tmp.ExeScale(sql);
        return result;
    }
    //入住登记
    public int ruzhu(users tmp)
    {
        string sql = "insert into House(U_name,U_number,U_phone,U_rdate,U_tdate,U_prnum,G_number) values('"+ tmp.name +
            "','" + tmp.number +
            "','" + tmp.tel + 
            "','" + tmp.rte +
            "','" + tmp.tte +
            "','" + tmp.penson + 
            "','" + tmp.num + "' )";
        int result = 0;
        result = tmp.ExeNnQuery(sql);
        return  result;
        
    }
    public int add(users tmp)
    {
        string sql="insert into Guest(G_number,G_price,G_type,G_money)values('"+tmp .num+
        "','"+price +
        "','"+type +
        "','"+money +"')";
        int result = 0;
        result = tmp.ExeNnQuery(sql);
        return result;
    }
    //预定
    public int yuding(users tmp)
    {
        string sql = "insert into House(U_name,U_number,U_phone,U_rdate,U_tdate,U_prnum,G_type) values('" + tmp.name +
            "','" + tmp.number +
            "','" + tmp.tel +
            "','" + tmp.rte +
            "','" + tmp.tte +
            "','" + tmp.penson +
            "','" + tmp.type + "' )";
        int result = 0;
        result = tmp.ExeNnQuery(sql);
        return result;

    }

    //查询客房信息
    public DataSet  GetAll(users tmp)
    {
        string sql = "select * from Guest";
       // users tmp = new users();
        DataSet ds = tmp.GetDs(sql);
        return ds;
    }
    //查询已住房信息
    public DataSet Gets(users tmp)
    {
        string sql = "select * from House ";
        // users tmp = new users();
        DataSet ds = tmp.GetDs(sql);
        return ds;
    }
    public DataSet Geton(users us)
    {

        string sql = "select * from House where  U_number='" + us.number + "'";
        DataSet ds = us.GetDs(sql);
        return ds;
    }

    //调房
    public DataSet Getone(users us)
    {

        string sql = "select * from House where  U_number='" + us.number +  "'";
        DataSet ds = us.GetDs(sql);
        return ds;
    }
    //订单
    public DataSet GetD(users us)
    {

        string sql = "select * from House where  U_id='" + us.id + "'";
        DataSet ds = us.GetDs(sql);
        return ds;
    }
    public DataSet Getone1(users us)
    {

        string sql = "select * from Guest where  G_type='" + us.type + "'";
        DataSet ds = us.GetDs(sql);
        return ds;
    }
    //删除
    public int delete(users us)
    {
        string sql = "delete from Guest where G_number='" + us.num + "'";
        int result = us.ExeNnQuery(sql);
        return result;
    }
    public int Delete(users us)
    {
        string sql = "delete from House where U_number='" + us.number + "'";
        int result = us.ExeNnQuery(sql);
        return result;
    }
    //更新客房信息
    public int Updahu(users us)
    {
        string sql = "update Guest set G_price='" + us.price + 
            "',G_type='" +us.type +

            "',G_money='" +us.money +

            "',G_free='" +us.free + 

            "' where G_number='"+ us.num +"'";
        int result = us.ExeNnQuery(sql);
        return result;
    }
    //客户信息
    public int Updahu2(users us)
    {
        string sql = "update House set U_name='" + us.name +
             "',U_phone='" + us.tel +

             "',U_rdate='" + us.rte +

             "',U_tdate='" + us.tte +

             "',U_prnum='" + us.penson + 

             "',G_number='"+us.num +
          
             "',G_type='" + us.type +

             "' where U_number='" + us.number + "'";
        int result = us.ExeNnQuery(sql);
        return result;
    }
    //调房  续房
    public int Updahu1(users us)
    {
        string sql = "update House set U_name='" + us.name +
            "',U_phone='"+us.tel+
            "',U_rdate='"+us.rte +
            "',U_tdate='"+us.tte+
            "',U_prnum='"+us.penson+
            "',G_number='"+us.num+
            "',G_type='"+us.type+
            "',G_free='"+us.free+
            "' where U_number='" + us.number + "'";
        int result = us.ExeNnQuery(sql);
        return result;
    }
    //退房
    public int UpdahT(users us)
    {
        string sql = "update House set U_name='" + us.name +
            "',U_phone='" + us.tel +
            "',U_rdate='" + us.rte +
            "',U_tdate='" + us.tte +
            "',U_prnum='" + us.penson +
           "',U_number='" + us.number +           
            "',G_free='" + us.free +                        
            "' where G_number='" + us.num + "'";
        int result = us.ExeNnQuery(sql);
        return result;
    }

    public int UpT(users us)
    {
        string sql = "update House set G_number='" + us.num +"'where U_number='" + us.number + "'";
        int result = us.ExeNnQuery (sql );
        return result;
    }
    public int getkcg(users us)
    {
        string sql = "select * from House where U_tdate<='" + us.tte + "'";
        int re = us.ExeNnQuery (sql);
        return re;
    }
    public DataSet Getorder(users us)
    {

        string sql = "select * from House where  U_id='" + us.id + "'";
        DataSet ds = us.GetDs(sql);
        return ds;
    }

}